/**
 * Arvore de Elementos do Layout
 *
 * @this {UITreeView}
 * @version
 */

function UITreeView() {

    /**
     * Variaveis
     */
    var _oTreeView = null;

    /**
     * Inicializa o objeto da classe
     */
    this.init = function() {

        _oTreeView = new YAHOO.widget.TreeView("elementstreeview");

        var oTmpNode = new YAHOO.widget.TextNode(EAppLabels.eTLayoutNickName, _oTreeView.getRoot(), false);
        oTmpNode.labelStyle = "icon-tlayout";

        _oTreeView.subscribe("labelClick", function(oNode) {
            if (oNode.label != EAppLabels.eTLayoutNickName) {
                var oLayoutComposer = ModelInstance.getLayoutComposer();
                var oUIProperties = UIInstance.getUIPropertiesInstance();
                oLayoutComposer.editPropertiesElement(oLayoutComposer.getElementByNickName(oNode.label));
                oUIProperties.showProperties();
            }
        });

        _oTreeView.draw();

    }

    /**
     * Funcoes
     */
    this.addNodeTreeView = function (elementNickName, elementType) {

        var oNewNode = new YAHOO.widget.TextNode(elementNickName, _oTreeView.getNodeByIndex(1), false);

        switch (elementType) {

            case EElementType.eTImage:
                oNewNode.labelStyle = "icon-timage";
                break;
            case EElementType.eTLabel:
                oNewNode.labelStyle = "icon-tlabel";
                break;
        }
        _oTreeView.expandAll();
        _oTreeView.draw();
    }

    this.remNodeTreeView = function (elementNickName) {
        var oNode = _oTreeView.getNodeByProperty("label", elementNickName);
        _oTreeView.removeNode(oNode, true);
    }

    /**
     * Chamada do inicializador da classe
     */
    this.init();
}

